package org.example.zsfmybatis.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.zsfmybatis.model.Restaurant;

import java.util.List;

@Mapper
public interface RestaurantMapper extends BaseMapper<Restaurant> {
    @Select("select * from restaurant")
    public List<Restaurant> getAllRestaurants();
    @Insert("insert into restaurant(restaurant_id,name,address,rating,created_at,updated_at)values " +
            "(#{restaurantId},#{name},#{address},#{rating},now(),now())")
    void add(Restaurant restaurant);
    @Update("update restaurant set name=#{name},address=#{address},rating=#{rating} where restaurant_id=#{id}")
    void update(int id,String name,String address,double rating);
    @Delete("delete from restaurant where restaurant_id=#{id}")
    void delete(int id);

}